--
-- DESCRIPTION
--
-- @COMPANY **
-- @AUTHOR **
-- @DATE ${date} ${time}
--

---@type BP_AbilityPickup_C
local M = UnLua.Class()

local BP_ActionCharClass = UE.UClass.Load("/Script/Engine.Blueprint'/ActionPlatformer/Blueprints/Characters/BP_ActionChar.BP_ActionChar_C'")

-- function M:Initialize(Initializer)
-- end

--- 初始化绑定相关
function M:InitializingBinding()
    self.PlayerCheck.OnComponentBeginOverlap:Add(self, self.OnComponentBeginOverlap_PlayerCheck)
end

-- function M:UserConstructionScript()
-- end

function M:ReceiveBeginPlay()
    self:InitializingBinding()
end

-- function M:ReceiveEndPlay()
-- end

-- function M:ReceiveTick(DeltaSeconds)
-- end

-- function M:ReceiveAnyDamage(Damage, DamageType, InstigatedBy, DamageCauser)
-- end

-- function M:ReceiveActorBeginOverlap(OtherActor)
-- end

-- function M:ReceiveActorEndOverlap(OtherActor)
-- end

function M:OnComponentBeginOverlap_PlayerCheck(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, FromSweep, SweepResult)
    self.OverlapActionChar = OtherActor:Cast(BP_ActionCharClass)
    if self.OverlapActionChar and self.OverlapActionChar.Faction == 0 then
        self.OverlapActionChar:GainAbility(self.AbilityType)
        self:K2_DestroyActor()
    end
end

return M
